/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CadastroAdvogado2.java
 *
 * Created on 27/08/2013, 20:46:05
 */
package Tela;

import Bean.CadastroAdvogadoBean;
import Dao.CadastroAdvogadoDao;
import Utils.UtilInterface;
import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException;
import java.awt.Color;
import java.sql.SQLException;
import java.util.List;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author william
 */
public class CadastroAdvogado2 extends javax.swing.JDialog {
 private List<CadastroAdvogadoBean> listaAdvogado;
    private int id = 0;
    private boolean salvar = true;
    private String tipo = "nome";

    /** Creates new form CadastroAdvogado2 */
    public CadastroAdvogado2(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        setLocationRelativeTo(null);
        botoesInical();
       atualizarTabela();
    }public void botoesInical() {
        btnNovo.setEnabled(true);
        btnSalvar.setEnabled(false);
        btnAlterar.setEnabled(false);
        limpaCampos();
        bloqueiaCampos(false);
        //atualizarTabela();
        //btnExcluir.setEnabled(false);
    }

    public void bloqueiaCampos(boolean opc) {
        txNome.setEnabled(opc);
        txPai.setEnabled(opc);
        txMae.setEnabled(opc);
        txRg.setEnabled(opc);
        txCpf.setEnabled(opc);
        cbSexo.setEnabled(opc);
        txOab.setEnabled(opc);
        jDateNacimento.setEnabled(opc);
        txNaturalidade.setEnabled(opc);
        cbEstadoCivil.setEnabled(opc);
        txBairro.setEnabled(opc);
        txCep.setEnabled(opc);
        txTelefone.setEnabled(opc);
        txNumero.setEnabled(opc);
        txCidade.setEnabled(opc);
        txCelular.setEnabled(opc);
        txEmail.setEnabled(opc);
        cbUfNascimento.setEnabled(opc);
        txEndereco.setEnabled(opc);
        cbEstado.setEnabled(opc);
        cbStatus.setEnabled(opc);
        txEspecialidade.setEnabled(opc);
        txUsuario.setEnabled(opc);
        txSenha.setEnabled(opc);
    }

    public void limpaCampos() {
        txNome.setText(null);
        txPai.setText(null);
        txMae.setText(null);
        txRg.setText(null);
        txCpf.setText(null);
        cbSexo.setSelectedIndex(0);
        txOab.setText(null);
        jDateNacimento.setDate(null);
        txNaturalidade.setText(null);
        cbEstadoCivil.setSelectedIndex(0);
        txBairro.setText(null);
        txCep.setText(null);
        txTelefone.setText(null);
        txNumero.setText(null);
        txCelular.setText(null);
        txEmail.setText(null);
        txCidade.setText(null);
        cbUfNascimento.setSelectedIndex(0);
        txEndereco.setText(null);
        cbEstado.setSelectedIndex(0);
        txEspecialidade.setText(null);
        txUsuario.setText(null);
        txSenha.setText(null);
    }

    private CadastroAdvogadoBean retornaObejeto() {
        CadastroAdvogadoBean pessoa = new CadastroAdvogadoBean();
        pessoa.setNome(txNome.getText().trim());
        pessoa.setPai(txPai.getText().trim());
        pessoa.setMae(txMae.getText().trim());
        pessoa.setNascimento(jDateNacimento.getDate());
        pessoa.setNaturalidade(txNaturalidade.getText().trim());
        pessoa.setRg(txRg.getText().trim());
        pessoa.setCpf(txCpf.getText().trim());
        pessoa.setSexo(cbSexo.getSelectedItem().toString());
        pessoa.setEstadocivil(cbEstadoCivil.getSelectedItem().toString());
        pessoa.setUfNascimento(cbUfNascimento.getSelectedItem().toString());
        pessoa.setOab(txOab.getText().trim());
        pessoa.setStatus(cbStatus.getSelectedItem().toString());
        pessoa.setEspecialidade(txEspecialidade.getText().trim());
        
        pessoa.setCidade(txCidade.getText().trim());
        pessoa.setEndereco(txEndereco.getText().trim());
        pessoa.setNumeroCasa(txNumero.getText().trim());
        pessoa.setBairro(txBairro.getText().trim());
        pessoa.setCep(txCep.getText().trim());
        pessoa.setCelular(txCelular.getText().trim());
        pessoa.setEmail(txEmail.getText().trim());
        pessoa.setTelefone(txTelefone.getText().trim());
        pessoa.setEstado(cbEstado.getSelectedItem().toString());
        
        pessoa.setUsuario(txUsuario.getText().trim());
        pessoa.setSenha(txSenha.getText().trim());

        pessoa.setIdavogado(id);
        return pessoa;
    }

    private boolean verificaCampos() {

        boolean v = true;

        if (!validaCpf(txCpf.getText())) {
            v = false;
            UtilInterface.msgErro("O CPF CONTINUA INVALIDO");
            txCpf.setBackground(UtilInterface.COR_ERRO);
        }


//        if (salvar == true) {
//            for (CadastroAdvogadoBean c : listaAdvogado) {
//                if (txCpf.getText().equals(c.getCpf())) {
//                    v = false;
//                    UtilInterface.msgErro("CPF já existe");
//                }
//            }
//        }


        if (txNome.getText().trim().equals("")) {
            v = false;
            txNome.setBackground(UtilInterface.COR_ERRO);
        } else {
            txNome.setBackground(UtilInterface.COR_SUCESSO);
        }

       if (jDateNacimento.getCalendar() == null) {
            v = false;
            jDateNacimento.setBackground(UtilInterface.COR_ERRO);
        } else {
            jDateNacimento.setBackground(UtilInterface.COR_SUCESSO);
        }

        if (txNaturalidade.getText().trim().equals("")) {
            v = false;
            txNaturalidade.setBackground(UtilInterface.COR_ERRO);
        } else {
            txNaturalidade.setBackground(UtilInterface.COR_SUCESSO);
        }

        if (txRg.getText().trim().equals("")) {
            v = false;
            txRg.setBackground(UtilInterface.COR_ERRO);
        } else {
            txRg.setBackground(UtilInterface.COR_SUCESSO);
        }


        if (txCpf.getText().equals("   .   .   -  ")) {
            txCpf.setBackground(UtilInterface.COR_ERRO);
        } else {
            txCpf.setBackground(UtilInterface.COR_SUCESSO);

        }

        if (cbSexo.getSelectedIndex() == 0) {
            v = false;
            cbSexo.setBackground(UtilInterface.COR_ERRO);
        } else {
            cbSexo.setBackground(UtilInterface.COR_SUCESSO);
        }

        if (cbEstadoCivil.getSelectedIndex() == 0) {
            v = false;
            cbEstadoCivil.setBackground(UtilInterface.COR_ERRO);
        } else {
            cbEstadoCivil.setBackground(UtilInterface.COR_SUCESSO);
        }
        if (txOab.getText().trim().equals("")) {
            v = false;
            txOab.setBackground(UtilInterface.COR_ERRO);
        } else {
            txOab.setBackground(UtilInterface.COR_SUCESSO);
        }
         if (txEspecialidade.getText().trim().equals("")) {
            v = false;
            txEspecialidade.setBackground(UtilInterface.COR_ERRO);
        } else {
            txEspecialidade.setBackground(UtilInterface.COR_SUCESSO);
        }
        
        if (cbUfNascimento.getSelectedIndex() == 0) {
            v = false;
            cbUfNascimento.setBackground(UtilInterface.COR_ERRO);
        } else {
            cbUfNascimento.setBackground(UtilInterface.COR_SUCESSO);
        }

        if (txEndereco.getText().trim().equals("")) {
            v = false;
            txEndereco.setBackground(UtilInterface.COR_ERRO);
        } else {
            txEndereco.setBackground(UtilInterface.COR_SUCESSO);
        }

        if (txBairro.getText().trim().equals("")) {
            v = false;
            txBairro.setBackground(UtilInterface.COR_ERRO);
        } else {
            txBairro.setBackground(UtilInterface.COR_SUCESSO);
        }

        if (txCidade.getText().trim().equals("")) {
            v = false;
            txCidade.setBackground(UtilInterface.COR_ERRO);
        } else {
            txCidade.setBackground(UtilInterface.COR_SUCESSO);
        }

        if (txCelular.getText().trim().equals("")) {
            v = false;
            txCelular.setBackground(UtilInterface.COR_ERRO);
        } else {
            txCelular.setBackground(UtilInterface.COR_SUCESSO);
        }

        if (txNumero.getText().trim().equals("")) {
            v = false;
            txNumero.setBackground(UtilInterface.COR_ERRO);
        } else {
            txNumero.setBackground(UtilInterface.COR_SUCESSO);
        }

        if (txCep.getText().equals("     -   ")) {
            v = false;
            txCep.setBackground(UtilInterface.COR_ERRO);
        } else {
            txCep.setBackground(UtilInterface.COR_SUCESSO);
        }

        if (cbEstado.getSelectedIndex() == 0) {
            v = false;
            cbEstado.setBackground(UtilInterface.COR_ERRO);
        } else {
            cbEstado.setBackground(UtilInterface.COR_SUCESSO);
        }
        if (txCelular.getText().equals("(  )    -    ")) {
            v = false;
            txCelular.setBackground(UtilInterface.COR_ERRO);
        } else {
            txCelular.setBackground(UtilInterface.COR_SUCESSO);
        }
        
        if (txUsuario.getText().trim().equals("")) {
            v = false;
            txUsuario.setBackground(UtilInterface.COR_ERRO);
        } else {
            txUsuario.setBackground(UtilInterface.COR_SUCESSO);
        }
        
        if (txSenha.getText().trim().equals("")) {
            v = false;
            txSenha.setBackground(UtilInterface.COR_ERRO);
        } else {
            txSenha.setBackground(UtilInterface.COR_SUCESSO);
        }
        

        if (!v) {
            Utils.UtilInterface.msgErro("PREENCHA OS CAMPOS OBRIGATORIOS!");

        }
        return v;
    }

    public void atualizarTabela() {
        DefaultTableModel modelo = (DefaultTableModel) tblAdvogado.getModel();
        modelo.setNumRows(0);
        try {
            listaAdvogado = CadastroAdvogadoDao.getLista();
            for (CadastroAdvogadoBean c : listaAdvogado) {
                modelo.addRow(new Object[]{c.getNome(), c.getCpf()});
            }
        } catch (SQLException ex) {
            UtilInterface.msgErro("ERRO AO ATUALIZAR TABELA\n" + ex);
        }
    }

    public static boolean validaCpf(String cpf) {
        boolean retorno = true;
        String cpfV = "";
        if (cpf.matches("^\\d{3}\\.\\d{3}\\.\\d{3}-\\d{2}$")) {
            try {
                cpf = cpf.replace(".", "");
                cpf = cpf.replace("-", "");

                for (int i = 0; i <= 9; i++) {
                    cpfV = "";

                    for (int j = 1; j <= 11; j++) {
                        cpfV += i;
                    }
                    if (cpfV.equals(cpf)) {
                        return false;
                    }
                }
                int digito[] = new int[11];
                int dvInformado = Integer.parseInt(cpf.substring(9, 11));
                for (int i = 0; i <= 8; i++) {
                    digito[i] = Integer.parseInt(cpf.substring(i, i + 1));
                }
                int posicao = 10;
                int soma = 0;
                for (int i = 0; i <= 8; i++) {
                    soma = (soma + digito[i] * posicao);
                    posicao = (posicao - 1);
                }
                digito[9] = (soma % 11);
                if (digito[9] < 2) {
                    digito[9] = 0;
                } else {
                    digito[9] = (11 - digito[9]);
                }
                posicao = 11;
                soma = 0;

                for (int i = 0; i <= 9; i++) {
                    soma = (soma + digito[i] * posicao);
                    posicao = (posicao - 1);
                }
                digito[10] = (soma % 11);
                if (digito[10] < 2) {
                    digito[10] = 0;
                } else {
                    digito[10] = (11 - digito[10]);
                }
                int dv = (digito[9] * 10 + digito[10]);
                if (dv != dvInformado) {
                    retorno = false;
                }
            } catch (Exception e) {
                retorno = false;

            }
        } else {
            retorno = false;
        }

        return retorno;
    }

    private void preencheCampos() {
        CadastroAdvogadoBean advogado = listaAdvogado.get(tblAdvogado.getSelectedRow());
        id = advogado.getIdavogado();
        txNome.setText(advogado.getNome());
        txPai.setText(advogado.getPai());
        txMae.setText(advogado.getMae());
        jDateNacimento.setDate(advogado.getNascimento());
        txNaturalidade.setText(advogado.getNaturalidade());
        cbEstadoCivil.setSelectedItem(advogado.getEstadocivil());
        cbUfNascimento.setSelectedItem(advogado.getUfNascimento());
        txRg.setText(advogado.getRg());
        txCpf.setText(advogado.getCpf());
        txEspecialidade.setText(advogado.getEspecialidade());
        cbSexo.setSelectedItem(advogado.getSexo());
        txEndereco.setText(advogado.getEndereco());
        txBairro.setText(advogado.getBairro());
        txCidade.setText(advogado.getCidade());
        txCelular.setText(advogado.getCelular());
        txTelefone.setText(advogado.getTelefone());
        txEmail.setText(advogado.getEmail());
        txNumero.setText(advogado.getNumeroCasa());
        txCep.setText(advogado.getCep());
        cbEstado.setSelectedItem(advogado.getEstado());
        txOab.setText(advogado.getOab());
        cbStatus.setSelectedItem(advogado.getStatus());
        txUsuario.setText(advogado.getUsuario());
        txSenha.setText(advogado.getSenha());
        bloqueiaCampos(false);
        btnNovo.setEnabled(true);
        btnSalvar.setEnabled(false);
        btnAlterar.setEnabled(true);
        //btnExcluir.setEnabled(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPDP = new javax.swing.JPanel();
        lbNome = new javax.swing.JLabel();
        lbPai = new javax.swing.JLabel();
        txPai = new javax.swing.JTextField();
        lbMae = new javax.swing.JLabel();
        txMae = new javax.swing.JTextField();
        lbCpf = new javax.swing.JLabel();
        lbRg = new javax.swing.JLabel();
        lbNascimento = new javax.swing.JLabel();
        lbNaturalidade = new javax.swing.JLabel();
        txNaturalidade = new javax.swing.JTextField();
        lbSexo = new javax.swing.JLabel();
        cbSexo = new javax.swing.JComboBox();
        lbUf = new javax.swing.JLabel();
        cbUfNascimento = new javax.swing.JComboBox();
        lbEstadoCivil = new javax.swing.JLabel();
        cbEstadoCivil = new javax.swing.JComboBox();
        txRg = new javax.swing.JFormattedTextField();
        txNome = new javax.swing.JFormattedTextField();
        txCpf = new javax.swing.JFormattedTextField();
        lbOab = new javax.swing.JLabel();
        txOab = new javax.swing.JFormattedTextField();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        lbEstadoCivil1 = new javax.swing.JLabel();
        cbStatus = new javax.swing.JComboBox();
        jDateNacimento = new com.toedter.calendar.JDateChooser();
        lbEspecialidade = new javax.swing.JLabel();
        txEspecialidade = new javax.swing.JTextField();
        jPDC = new javax.swing.JPanel();
        lbEndereco = new javax.swing.JLabel();
        lbBairro = new javax.swing.JLabel();
        txBairro = new javax.swing.JTextField();
        lbNumero = new javax.swing.JLabel();
        txEndereco = new javax.swing.JTextField();
        lbCidade = new javax.swing.JLabel();
        txCidade = new javax.swing.JTextField();
        lbEstado = new javax.swing.JLabel();
        cbEstado = new javax.swing.JComboBox();
        lbCelular = new javax.swing.JLabel();
        lbTelefone = new javax.swing.JLabel();
        lbCep = new javax.swing.JLabel();
        blEmail = new javax.swing.JLabel();
        txEmail = new javax.swing.JTextField();
        txCelular = new javax.swing.JFormattedTextField();
        txCep = new javax.swing.JFormattedTextField();
        txTelefone = new javax.swing.JFormattedTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        txNumero = new javax.swing.JTextField();
        jPU = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        txSenha = new javax.swing.JTextField();
        txUsuario = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        pCadastro = new javax.swing.JPanel();
        jSeparator1 = new javax.swing.JSeparator();
        lbCadastro1 = new javax.swing.JLabel();
        pBotoes = new javax.swing.JPanel();
        btnNovo = new javax.swing.JButton();
        btnSalvar = new javax.swing.JButton();
        btnAlterar = new javax.swing.JButton();
        btnPesquisar = new javax.swing.JButton();
        txpesquisa = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jRadioNome = new javax.swing.JRadioButton();
        jRadioCpf = new javax.swing.JRadioButton();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblAdvogado = new javax.swing.JTable();
        jLabel29 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPDP.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        lbNome.setText("NOME:");

        lbPai.setText("PAI:");

        txPai.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txPaiActionPerformed(evt);
            }
        });
        txPai.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txPaiFocusLost(evt);
            }
        });
        txPai.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txPaiKeyTyped(evt);
            }
        });

        lbMae.setText("MÃE:");

        txMae.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txMaeActionPerformed(evt);
            }
        });
        txMae.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txMaeFocusLost(evt);
            }
        });
        txMae.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txMaeKeyTyped(evt);
            }
        });

        lbCpf.setText("CPF:");

        lbRg.setText("RG:");

        lbNascimento.setText("NASCIMENTO:");

        lbNaturalidade.setText("NATURALIDADE:");

        txNaturalidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txNaturalidadeActionPerformed(evt);
            }
        });
        txNaturalidade.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txNaturalidadeFocusLost(evt);
            }
        });
        txNaturalidade.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txNaturalidadeKeyTyped(evt);
            }
        });

        lbSexo.setText("SEXO:");

        cbSexo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SELECIONAR", "MASCULINO", "FEMININO" }));

        lbUf.setText("UF:");

        cbUfNascimento.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SELECIONAR", "ACRE", "ALAGOAS", "AMAPÁ", "AMAZONAS", "BAHIA", "CEARÁ", "DISTRITO FEDERAL", "ESPÍRITO SANTO", "GOIÁS", "MARANHÃO", "MATO GROSSO", "MATO GROSSO DO SUL", "MINAS GERAIS", "PARÁ", "PARAÍBA", "PARANÁ", "PERNAMBUCO", "PIAUÍ", "RIO DE JANEIRO", "RIO GRANDE DO NORTE", "RIO GRANDE DO SUL", "RONDÔNIA", "RORAIMA", "SANTA CATARINA", "SÃO PAULO", "SERGIPE", "TOCANTINS" }));
        cbUfNascimento.setToolTipText("escolha o estado de nascimento");

        lbEstadoCivil.setText("ESTADO CIVIL:");

        cbEstadoCivil.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SELECIONAR", "SOLTEIRO", "CASADO", "VIUVO", "DIVORCIADO", "AMASIADO" }));

        txRg.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txRgKeyTyped(evt);
            }
        });

        txNome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txNomeActionPerformed(evt);
            }
        });
        txNome.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txNomeFocusLost(evt);
            }
        });
        txNome.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txNomeKeyTyped(evt);
            }
        });

        try {
            txCpf.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###.###.###-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txCpf.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txCpfFocusLost(evt);
            }
        });

        lbOab.setText("OAB:");

        txOab.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txOabActionPerformed(evt);
            }
        });
        txOab.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txOabKeyTyped(evt);
            }
        });

        jLabel20.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel20.setForeground(new java.awt.Color(255, 0, 51));
        jLabel20.setText("*");

        jLabel21.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel21.setForeground(new java.awt.Color(255, 0, 51));
        jLabel21.setText("*");

        jLabel22.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel22.setForeground(new java.awt.Color(255, 0, 51));
        jLabel22.setText("*");

        jLabel23.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel23.setForeground(new java.awt.Color(255, 0, 51));
        jLabel23.setText("*");

        jLabel24.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel24.setForeground(new java.awt.Color(255, 0, 51));
        jLabel24.setText("*");

        jLabel25.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel25.setForeground(new java.awt.Color(255, 0, 51));
        jLabel25.setText("*");

        jLabel26.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel26.setForeground(new java.awt.Color(255, 0, 51));
        jLabel26.setText("*");

        jLabel27.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel27.setForeground(new java.awt.Color(255, 0, 51));
        jLabel27.setText("*");

        lbEstadoCivil1.setText("STATUS");

        cbStatus.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ATIVO", "INATIVO" }));

        jDateNacimento.setIcon(null);

        lbEspecialidade.setText("ESPECIALIDADE");

        txEspecialidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txEspecialidadeActionPerformed(evt);
            }
        });
        txEspecialidade.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txEspecialidadeFocusLost(evt);
            }
        });
        txEspecialidade.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txEspecialidadeKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPDPLayout = new javax.swing.GroupLayout(jPDP);
        jPDP.setLayout(jPDPLayout);
        jPDPLayout.setHorizontalGroup(
            jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPDPLayout.createSequentialGroup()
                .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPDPLayout.createSequentialGroup()
                        .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel20)
                            .addComponent(jLabel21))
                        .addGap(10, 10, 10)
                        .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPDPLayout.createSequentialGroup()
                                .addComponent(lbNaturalidade)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(txNaturalidade, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE))
                            .addGroup(jPDPLayout.createSequentialGroup()
                                .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(lbNome, javax.swing.GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE)
                                    .addComponent(lbMae, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(lbPai))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txMae, javax.swing.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE)
                                    .addComponent(txPai, javax.swing.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE)
                                    .addComponent(txNome, javax.swing.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE)))))
                    .addGroup(jPDPLayout.createSequentialGroup()
                        .addComponent(jLabel22)
                        .addGap(10, 10, 10)
                        .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPDPLayout.createSequentialGroup()
                                .addComponent(lbNascimento)
                                .addGap(21, 21, 21)
                                .addComponent(jDateNacimento, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel23)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(lbEstadoCivil)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
                                .addComponent(cbEstadoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPDPLayout.createSequentialGroup()
                                .addComponent(lbEspecialidade)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(txEspecialidade, javax.swing.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE)))))
                .addGap(27, 27, 27)
                .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPDPLayout.createSequentialGroup()
                        .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel26)
                            .addComponent(jLabel25))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbRg, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbCpf)
                            .addComponent(lbSexo))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(jPDPLayout.createSequentialGroup()
                        .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPDPLayout.createSequentialGroup()
                                .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jPDPLayout.createSequentialGroup()
                                        .addComponent(jLabel24)
                                        .addGap(5, 5, 5))
                                    .addGroup(jPDPLayout.createSequentialGroup()
                                        .addComponent(jLabel27)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                                .addComponent(lbUf))
                            .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(lbEstadoCivil1)
                                .addComponent(lbOab)))
                        .addGap(18, 18, 18)))
                .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPDPLayout.createSequentialGroup()
                        .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txRg, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE)
                            .addComponent(cbUfNascimento, 0, 0, Short.MAX_VALUE)
                            .addComponent(txOab, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE)
                            .addGroup(jPDPLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txCpf, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE))
                            .addComponent(cbSexo, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(43, 43, 43))
                    .addGroup(jPDPLayout.createSequentialGroup()
                        .addComponent(cbStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );
        jPDPLayout.setVerticalGroup(
            jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPDPLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbRg, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPDPLayout.createSequentialGroup()
                        .addComponent(txRg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lbCpf)
                            .addComponent(jLabel25)
                            .addComponent(txCpf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(21, 21, 21)
                        .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbSexo, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lbSexo)
                                .addComponent(jLabel26))))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPDPLayout.createSequentialGroup()
                        .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(cbUfNascimento, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lbUf)
                                    .addComponent(jLabel27))
                                .addGroup(jPDPLayout.createSequentialGroup()
                                    .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(lbNome)
                                        .addComponent(txNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel20))
                                    .addGap(18, 18, 18)
                                    .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(lbPai)
                                        .addComponent(txPai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGap(18, 18, 18)
                                    .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(lbMae, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(txMae, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGap(18, 18, 18)
                                    .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(lbNaturalidade)
                                        .addComponent(txNaturalidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel21))))
                            .addComponent(jLabel24))
                        .addGap(18, 18, 18)
                        .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lbNascimento)
                                .addComponent(cbEstadoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel22)
                                .addComponent(lbEstadoCivil)
                                .addComponent(jLabel23)
                                .addComponent(txOab, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lbOab))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPDPLayout.createSequentialGroup()
                                .addComponent(jDateNacimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(3, 3, 3)))))
                .addGap(18, 18, 18)
                .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lbEspecialidade)
                        .addComponent(txEspecialidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPDPLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lbEstadoCivil1)
                        .addComponent(cbStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(42, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("DADOS PRINCIPAIS", jPDP);

        jPDC.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPDC.setForeground(new java.awt.Color(255, 0, 0));

        lbEndereco.setText("ENDEREÇO:");

        lbBairro.setText("BAIRRO:");

        txBairro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txBairroActionPerformed(evt);
            }
        });
        txBairro.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txBairroFocusLost(evt);
            }
        });
        txBairro.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txBairroKeyTyped(evt);
            }
        });

        lbNumero.setText("NUMERO:");

        txEndereco.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txEnderecoFocusLost(evt);
            }
        });
        txEndereco.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txEnderecoKeyTyped(evt);
            }
        });

        lbCidade.setText("CIDADE:");

        txCidade.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txCidadeFocusLost(evt);
            }
        });
        txCidade.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txCidadeKeyTyped(evt);
            }
        });

        lbEstado.setText("ESTADO:");

        cbEstado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SELECIONAR", "ACRE", "ALAGOAS", "AMAPÁ", "AMAZONAS", "BAHIA", "CEARÁ", "DISTRITO FEDERAL", "ESPÍRITO SANTO", "GOIÁS", "MARANHÃO", "MATO GROSSO", "MATO GROSSO DO SUL", "MINAS GERAIS", "PARÁ", "PARAÍBA", "PARANÁ", "PERNAMBUCO", "PIAUÍ", "RIO DE JANEIRO", "RIO GRANDE DO NORTE", "RIO GRANDE DO SUL", "RONDÔNIA", "RORAIMA", "SANTA CATARINA", "SÃO PAULO", "SERGIPE", "TOCANTINS" }));

        lbCelular.setText("CELULAR:");

        lbTelefone.setText("TELEFONE:");

        lbCep.setText("CEP:");

        blEmail.setText("EMAIL:");

        txEmail.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txEmailActionPerformed(evt);
            }
        });
        txEmail.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txEmailKeyTyped(evt);
            }
        });

        try {
            txCelular.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        try {
            txCep.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("#####-###")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txCep.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txCepActionPerformed(evt);
            }
        });

        try {
            txTelefone.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel12.setForeground(new java.awt.Color(255, 0, 51));
        jLabel12.setText("*");

        jLabel13.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel13.setForeground(new java.awt.Color(255, 0, 51));
        jLabel13.setText("*");

        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel14.setForeground(new java.awt.Color(255, 0, 51));
        jLabel14.setText("*");

        jLabel15.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel15.setForeground(new java.awt.Color(255, 0, 51));
        jLabel15.setText("*");

        jLabel16.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel16.setForeground(new java.awt.Color(255, 0, 51));
        jLabel16.setText("*");

        jLabel18.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel18.setForeground(new java.awt.Color(255, 0, 51));
        jLabel18.setText("*");

        jLabel19.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel19.setForeground(new java.awt.Color(255, 0, 51));
        jLabel19.setText("*");

        txNumero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txNumeroActionPerformed(evt);
            }
        });
        txNumero.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txNumeroKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPDCLayout = new javax.swing.GroupLayout(jPDC);
        jPDC.setLayout(jPDCLayout);
        jPDCLayout.setHorizontalGroup(
            jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPDCLayout.createSequentialGroup()
                .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12)
                    .addComponent(jLabel13)
                    .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel15, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbEndereco)
                    .addComponent(lbCelular)
                    .addComponent(lbBairro)
                    .addComponent(blEmail)
                    .addComponent(lbCidade))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPDCLayout.createSequentialGroup()
                        .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txEndereco, javax.swing.GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE)
                            .addComponent(txBairro)
                            .addComponent(txCidade)
                            .addComponent(txEmail))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 52, Short.MAX_VALUE)
                        .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel16, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel18, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel19, javax.swing.GroupLayout.Alignment.TRAILING)))
                    .addComponent(txCelular, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPDCLayout.createSequentialGroup()
                        .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbTelefone, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPDCLayout.createSequentialGroup()
                                .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lbCep)
                                    .addComponent(lbEstado))
                                .addGap(10, 10, 10)))
                        .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPDCLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(cbEstado, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txTelefone)))
                            .addGroup(jPDCLayout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(txCep, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE))))
                    .addGroup(jPDCLayout.createSequentialGroup()
                        .addComponent(lbNumero)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txNumero, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)))
                .addGap(148, 148, 148))
        );
        jPDCLayout.setVerticalGroup(
            jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPDCLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbEndereco)
                    .addComponent(lbNumero)
                    .addComponent(txEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12)
                    .addComponent(jLabel16)
                    .addComponent(txNumero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbBairro)
                    .addComponent(lbCep)
                    .addComponent(txBairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txCep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13)
                    .addComponent(jLabel18))
                .addGap(16, 16, 16)
                .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbCidade)
                    .addComponent(lbEstado)
                    .addComponent(cbEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14)
                    .addComponent(jLabel19))
                .addGap(18, 18, 18)
                .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txCelular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lbCelular)
                        .addComponent(lbTelefone)
                        .addComponent(txTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel15)))
                .addGap(18, 18, 18)
                .addGroup(jPDCLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(blEmail)
                    .addComponent(txEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(124, 124, 124))
        );

        jTabbedPane1.addTab("DADOS COMPLEMENTARES", jPDC);

        jPU.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPU.setForeground(new java.awt.Color(255, 0, 0));

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.setForeground(new java.awt.Color(255, 0, 0));

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel3.setText("usuario ");

        txSenha.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txSenha.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txSenhaKeyTyped(evt);
            }
        });

        txUsuario.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txUsuarioActionPerformed(evt);
            }
        });
        txUsuario.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txUsuarioKeyTyped(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel4.setText("senha ");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(7, 7, 7))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txSenha, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)
                    .addComponent(txUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txUsuario)
                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPULayout = new javax.swing.GroupLayout(jPU);
        jPU.setLayout(jPULayout);
        jPULayout.setHorizontalGroup(
            jPULayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPULayout.createSequentialGroup()
                .addGap(192, 192, 192)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(235, Short.MAX_VALUE))
        );
        jPULayout.setVerticalGroup(
            jPULayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPULayout.createSequentialGroup()
                .addGap(83, 83, 83)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(88, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("LOGIN", jPU);

        lbCadastro1.setFont(new java.awt.Font("Script MT Bold", 1, 36));
        lbCadastro1.setText("Cadastro de Advogado ");
        lbCadastro1.setToolTipText("");

        javax.swing.GroupLayout pCadastroLayout = new javax.swing.GroupLayout(pCadastro);
        pCadastro.setLayout(pCadastroLayout);
        pCadastroLayout.setHorizontalGroup(
            pCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 722, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pCadastroLayout.createSequentialGroup()
                .addContainerGap(199, Short.MAX_VALUE)
                .addComponent(lbCadastro1)
                .addGap(145, 145, 145))
        );
        pCadastroLayout.setVerticalGroup(
            pCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pCadastroLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbCadastro1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 11, Short.MAX_VALUE))
        );

        pBotoes.setBackground(new java.awt.Color(204, 204, 204));
        pBotoes.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        pBotoes.setForeground(new java.awt.Color(51, 51, 255));

        btnNovo.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14));
        btnNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Add.png"))); // NOI18N
        btnNovo.setText("NOVO");
        btnNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovoActionPerformed(evt);
            }
        });
        pBotoes.add(btnNovo);

        btnSalvar.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14));
        btnSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Save.png"))); // NOI18N
        btnSalvar.setText("SALVAR");
        btnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalvarActionPerformed(evt);
            }
        });
        pBotoes.add(btnSalvar);

        btnAlterar.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14));
        btnAlterar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Modify.png"))); // NOI18N
        btnAlterar.setText("ALTERAR");
        pBotoes.add(btnAlterar);

        btnPesquisar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/View.png"))); // NOI18N
        btnPesquisar.setText("Pesquisar");
        btnPesquisar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPesquisarActionPerformed(evt);
            }
        });

        txpesquisa.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txpesquisaKeyReleased(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel1.setText("Pesquisar:");

        jRadioNome.setFont(new java.awt.Font("Tahoma", 0, 14));
        jRadioNome.setSelected(true);
        jRadioNome.setText("Nome");
        jRadioNome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioNomeActionPerformed(evt);
            }
        });

        jRadioCpf.setFont(new java.awt.Font("Tahoma", 0, 14));
        jRadioCpf.setText("CPF");
        jRadioCpf.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioCpfActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel2.setText("Pesquisar por");

        tblAdvogado.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "NOME", "CPF"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblAdvogado.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblAdvogadoMouseClicked(evt);
            }
        });
        tblAdvogado.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tblAdvogadoKeyReleased(evt);
            }
        });
        jScrollPane1.setViewportView(tblAdvogado);

        jLabel29.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel29.setText("Campos Obrigatorios");

        jLabel30.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel30.setForeground(new java.awt.Color(255, 0, 51));
        jLabel30.setText("*");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pCadastro, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 702, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pBotoes, javax.swing.GroupLayout.DEFAULT_SIZE, 702, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 712, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jRadioNome)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jRadioCpf))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(txpesquisa, javax.swing.GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnPesquisar)))
                        .addGap(109, 109, 109))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel30)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel29)
                        .addContainerGap(551, javax.swing.GroupLayout.PREFERRED_SIZE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(pCadastro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 305, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pBotoes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioNome)
                    .addComponent(jLabel2)
                    .addComponent(jRadioCpf))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txpesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnPesquisar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel30)
                    .addComponent(jLabel29))
                .addContainerGap(12, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
      
        
    private void txCpfFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txCpfFocusLost

        if (!validaCpf(txCpf.getText())) {             UtilInterface.msgErro("CPF INVALIDO");             txCpf.setBackground(UtilInterface.COR_ERRO);         }     }//GEN-LAST:event_txCpfFocusLost

    private void txEnderecoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txEnderecoFocusLost

        txEndereco.setText(txEndereco.getText().toUpperCase());     }//GEN-LAST:event_txEnderecoFocusLost

    private void txEnderecoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txEnderecoKeyTyped

        if (txEndereco.getText().length() > 55) {             UtilInterface.msgErro("Voce atingiu o limite de caracteres!\n Por favor abrevie");         }     }//GEN-LAST:event_txEnderecoKeyTyped

    private void txCidadeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txCidadeFocusLost

        txCidade.setText(txCidade.getText().toUpperCase());     }//GEN-LAST:event_txCidadeFocusLost

    private void txCidadeKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txCidadeKeyTyped

        if (txCidade.getText().length() > 55) {             UtilInterface.msgErro("Voce atingiu o limite de caracteres!\n Por favor abrevie");         }     }//GEN-LAST:event_txCidadeKeyTyped

        private void txCepActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txCepActionPerformed

        // TODO add your handling code here:}//GEN-LAST:event_txCepActionPerformed
        }
    
    
    
    
    private void txNaturalidadeKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txNaturalidadeKeyTyped
    if (txNaturalidade.getText().length() > 40) {    UtilInterface.msgErro("Voce atingiu o limite de caracteres!"); }
    }//GEN-LAST:event_txNaturalidadeKeyTyped

    private void txNaturalidadeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txNaturalidadeFocusLost
        txNaturalidade.setText(txNaturalidade.getText().toUpperCase());
    }//GEN-LAST:event_txNaturalidadeFocusLost

    private void txNaturalidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txNaturalidadeActionPerformed

    }//GEN-LAST:event_txNaturalidadeActionPerformed

    private void txPaiKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txPaiKeyTyped
    if (txPai.getText().length() > 55) {    UtilInterface.msgErro("Voce atingiu o limite de caracteres!"); }
    }//GEN-LAST:event_txPaiKeyTyped

    private void txPaiFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txPaiFocusLost
        txPai.setText(txPai.getText().toUpperCase());
    }//GEN-LAST:event_txPaiFocusLost

    private void txPaiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txPaiActionPerformed
        
    }//GEN-LAST:event_txPaiActionPerformed

    private void txNomeKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txNomeKeyTyped
        if (txNome.getText().length() > 55) {    UtilInterface.msgErro("Voce atingiu o limite de caracteres!"); }
    }//GEN-LAST:event_txNomeKeyTyped

    private void txNomeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txNomeFocusLost
        txNome.setText(txNome.getText().toUpperCase());
    }//GEN-LAST:event_txNomeFocusLost

    private void txNomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txNomeActionPerformed
    
    }//GEN-LAST:event_txNomeActionPerformed

    private void txOabKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txOabKeyTyped
          if (txOab.getText().length() > 10) {             UtilInterface.msgErro("Voce atingiu o limite de caracteres!");         }
    }//GEN-LAST:event_txOabKeyTyped

    private void txOabActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txOabActionPerformed

    }//GEN-LAST:event_txOabActionPerformed

    private void txBairroKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txBairroKeyTyped
            if (txBairro.getText().length() > 40) {             UtilInterface.msgErro("Voce atingiu o limite de caracteres!");         }
    }//GEN-LAST:event_txBairroKeyTyped

    private void txBairroFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txBairroFocusLost
        txBairro.setText(txBairro.getText().toUpperCase());
    }//GEN-LAST:event_txBairroFocusLost

    private void txBairroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txBairroActionPerformed

    }//GEN-LAST:event_txBairroActionPerformed

    private void txEmailKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txEmailKeyTyped

    }//GEN-LAST:event_txEmailKeyTyped

    private void txEmailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txEmailActionPerformed

    }//GEN-LAST:event_txEmailActionPerformed

    private void btnNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovoActionPerformed
        btnNovo.setEnabled(false);
        btnSalvar.setEnabled(true);
        btnAlterar.setEnabled(false);
        limpaCampos();
        bloqueiaCampos(true);
        txNome.requestFocus();
        salvar = true;
    }//GEN-LAST:event_btnNovoActionPerformed

    private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed
       if (verificaCampos()) {
            if (salvar) {
                try {
                    new CadastroAdvogadoDao().salvar(retornaObejeto());
                   atualizarTabela();
                    UtilInterface.msqSucesso(UtilInterface.MSG_SUC_SALVAR);
                    botoesInical();
                } catch (MySQLIntegrityConstraintViolationException ex) {
                    UtilInterface.msgErro("Ja existe este numero da OAB");
                    txOab.setBackground(Color.RED);
                } catch (SQLException e) {
                    UtilInterface.msgErro("Erro ao Salvar\n" + e);
                }
            } else {
                try {
                    CadastroAdvogadoDao.alterar(retornaObejeto());
                    //atualizarTabela();
                    UtilInterface.msqSucesso(UtilInterface.MSG_SUC_ALTERAR);
                    botoesInical();
                } catch (MySQLIntegrityConstraintViolationException ex) {
                    UtilInterface.msgErro("Ja existe este numero da OAB");
                    txOab.setBackground(Color.RED); 
                }catch (SQLException e) {
                    UtilInterface.msgErro("Erro ao Alterar\n" + e);
                }
            }
        }
    }//GEN-LAST:event_btnSalvarActionPerformed

    private void txEspecialidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txEspecialidadeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txEspecialidadeActionPerformed

    private void txNumeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txNumeroActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txNumeroActionPerformed

    private void txNumeroKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txNumeroKeyTyped
       if (txNumero.getText().length() > 10) {    UtilInterface.msgErro("Voce atingiu o limite de caracteres!"); }
    }//GEN-LAST:event_txNumeroKeyTyped

    private void tblAdvogadoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tblAdvogadoKeyReleased
            preencheCampos();
    }//GEN-LAST:event_tblAdvogadoKeyReleased

    private void tblAdvogadoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblAdvogadoMouseClicked
            preencheCampos();
    }//GEN-LAST:event_tblAdvogadoMouseClicked

    private void btnPesquisarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisarActionPerformed

    }//GEN-LAST:event_btnPesquisarActionPerformed

    private void jRadioNomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioNomeActionPerformed

    }//GEN-LAST:event_jRadioNomeActionPerformed

    private void txEspecialidadeKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txEspecialidadeKeyTyped
        if (txEspecialidade.getText().length() > 50) {    UtilInterface.msgErro("Voce atingiu o limite de caracteres!"); }        // TODO add your handling code here:
    }//GEN-LAST:event_txEspecialidadeKeyTyped

    private void txRgKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txRgKeyTyped
        if (txRg.getText().length() > 11) {UtilInterface.msgErro("Voce atingiu o limite de caracteres!");}
    }//GEN-LAST:event_txRgKeyTyped

    private void txEspecialidadeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txEspecialidadeFocusLost
        txEspecialidade.setText(txEspecialidade.getText().toUpperCase());
    }//GEN-LAST:event_txEspecialidadeFocusLost

    private void jRadioCpfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioCpfActionPerformed
        tipo = "cpf";  
    }//GEN-LAST:event_jRadioCpfActionPerformed

    private void txMaeKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txMaeKeyTyped
            if(txMae.getText().length() > 55) {    
            UtilInterface.msgErro("Voce atingiu o limite de caracteres!");
        } 
    }//GEN-LAST:event_txMaeKeyTyped

    private void txMaeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txMaeFocusLost
        txMae.setText(txMae.getText().toUpperCase());
    }//GEN-LAST:event_txMaeFocusLost

    private void txMaeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txMaeActionPerformed

    }//GEN-LAST:event_txMaeActionPerformed

    private void txpesquisaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txpesquisaKeyReleased
        //if (txpesquisa.getText().trim().isEmpty()) {             atualizarTabela();         }     } 
    }//GEN-LAST:event_txpesquisaKeyReleased

    private void txUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txUsuarioActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txUsuarioActionPerformed

    private void txUsuarioKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txUsuarioKeyTyped
        if(txUsuario.getText().length() > 10) {    
            UtilInterface.msgErro("Voce atingiu o limite de caracteres!");
        } 
    }//GEN-LAST:event_txUsuarioKeyTyped

    private void txSenhaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txSenhaKeyTyped
        if(txSenha.getText().length() > 20) {    
            UtilInterface.msgErro("Voce atingiu o limite de caracteres!");
        } 
    }//GEN-LAST:event_txSenhaKeyTyped

   
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CadastroAdvogado2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CadastroAdvogado2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CadastroAdvogado2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CadastroAdvogado2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                CadastroAdvogado2 dialog = new CadastroAdvogado2(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel blEmail;
    private javax.swing.JButton btnAlterar;
    private javax.swing.JButton btnNovo;
    private javax.swing.JButton btnPesquisar;
    private javax.swing.JButton btnSalvar;
    private javax.swing.JComboBox cbEstado;
    private javax.swing.JComboBox cbEstadoCivil;
    private javax.swing.JComboBox cbSexo;
    private javax.swing.JComboBox cbStatus;
    private javax.swing.JComboBox cbUfNascimento;
    private com.toedter.calendar.JDateChooser jDateNacimento;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPDC;
    private javax.swing.JPanel jPDP;
    private javax.swing.JPanel jPU;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton jRadioCpf;
    private javax.swing.JRadioButton jRadioNome;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel lbBairro;
    private javax.swing.JLabel lbCadastro1;
    private javax.swing.JLabel lbCelular;
    private javax.swing.JLabel lbCep;
    private javax.swing.JLabel lbCidade;
    private javax.swing.JLabel lbCpf;
    private javax.swing.JLabel lbEndereco;
    private javax.swing.JLabel lbEspecialidade;
    private javax.swing.JLabel lbEstado;
    private javax.swing.JLabel lbEstadoCivil;
    private javax.swing.JLabel lbEstadoCivil1;
    private javax.swing.JLabel lbMae;
    private javax.swing.JLabel lbNascimento;
    private javax.swing.JLabel lbNaturalidade;
    private javax.swing.JLabel lbNome;
    private javax.swing.JLabel lbNumero;
    private javax.swing.JLabel lbOab;
    private javax.swing.JLabel lbPai;
    private javax.swing.JLabel lbRg;
    private javax.swing.JLabel lbSexo;
    private javax.swing.JLabel lbTelefone;
    private javax.swing.JLabel lbUf;
    private javax.swing.JPanel pBotoes;
    private javax.swing.JPanel pCadastro;
    private javax.swing.JTable tblAdvogado;
    private javax.swing.JTextField txBairro;
    private javax.swing.JFormattedTextField txCelular;
    private javax.swing.JFormattedTextField txCep;
    private javax.swing.JTextField txCidade;
    private javax.swing.JFormattedTextField txCpf;
    private javax.swing.JTextField txEmail;
    private javax.swing.JTextField txEndereco;
    private javax.swing.JTextField txEspecialidade;
    private javax.swing.JTextField txMae;
    private javax.swing.JTextField txNaturalidade;
    private javax.swing.JFormattedTextField txNome;
    private javax.swing.JTextField txNumero;
    private javax.swing.JFormattedTextField txOab;
    private javax.swing.JTextField txPai;
    private javax.swing.JFormattedTextField txRg;
    private javax.swing.JTextField txSenha;
    private javax.swing.JFormattedTextField txTelefone;
    private javax.swing.JTextField txUsuario;
    private javax.swing.JTextField txpesquisa;
    // End of variables declaration//GEN-END:variables
}
